package com.hzit.bj01.service.impl;

import com.hzit.bj01.mapper.BillMapper;
import com.hzit.bj01.mapper.PaySerialInfoMapper;
import com.hzit.bj01.model.BillInfo;
import com.hzit.bj01.model.PaySerialInfo;
import com.hzit.bj01.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements IUserService {


    @Autowired
    private JdbcTemplate jdbcTemplate;


    @Autowired
    private BillMapper billMapper;


    @Autowired
    private PaySerialInfoMapper paySerialInfoMapper;


    @Override
    public void queryUser() {


        System.out.println("jdbcTemplate = " + jdbcTemplate);

        String sql = "insert tb_bill values(?,?,?,?,?,?) ";

        jdbcTemplate.update(sql,null,"test123","mch001",null,"order001",null);


    }

    @Override
    public void queryBillInfo() {

        //db1
//        List<BillInfo> billInfos = billMapper.queryAllBill();
//
//        System.out.println(billInfos);
//
//        //切换, AOP实现


        //db2
        PaySerialInfo paySerialInfo = paySerialInfoMapper.selectByPrimaryKey(29l);

        System.out.println(paySerialInfo);

    }
}
